package yxy.cherry.battle.module.affix.buff;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixContext.AffixTarget;
import yxy.cherry.battle.module.affix.AffixFactory.BuffTypeEnum;
import yxy.cherry.battle.module.affix.Buff;
import yxy.cherry.battle.module.affix.BuffType;
import yxy.cherry.data.bean.skill;

import java.util.ArrayList;

/** 减伤 */
@BuffType(Type = BuffTypeEnum.减伤)
public class Affix_60_减伤 extends Buff {

	private int get减伤比例() {
		return getParam(0);
	}

	public Affix_60_减伤(Fighter source, Fighter target, skill skilldata, int[] params) {
		super(source, target, skilldata, params);
	}

	@Override
	public boolean exec(Fighter source, Fighter target) {
		AffixTarget affixTarget = getAffixAction().getTarget(getAffixAction().get针对目标());

		//纵向叠加参数
		int overlay = 1;
		if (getOverlayMax() > 0) {
			overlay = getOverlay();
		}
		ArrayList<Long> 结算伤害流 = genReduceDamage(affixTarget.get伤害流(), affixTarget.getBaseDamageList(), get减伤比例()*overlay);

		Battle.battleLogger(6,"Buff减伤：施法者："+source.getName()+"对象："+affixTarget.get目标().getName()+"原始伤害："+affixTarget.get伤害流().toString()+"基本伤害："+affixTarget.getBaseDamageList().toString()+"增伤比例："+get减伤比例()+"叠加层数："+overlay+"最终伤害："+结算伤害流.toString());
		affixTarget.set伤害流(结算伤害流);

		return true;
	}

	@Override
	public BuffType getBuffType() {
		return BuffType.增益效果;
	}

	@Override
	public BuffStateType getBuffStateType() {
		return BuffStateType.减伤状态;
	}
}